package com.yunhe.task.client;

import com.yunhe.task.client.fallback.EnergyFallbackFactory;
import com.yunhe.common.model.DomainList;
import com.yunhe.common.model.ResultObject;
import com.yunhe.common.model.data.ElectricityDay;
import com.yunhe.common.model.data.ElectricityMonth;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

/**
 * 实时数据Feign客户端
 * @author liuronglei
 */
@FeignClient(value = "yh-energy", fallbackFactory = EnergyFallbackFactory.class)
public interface EnergyClient {

    /**
     * 新增电量（日）
     * @param electricity 电量对象
     */
    @RequestMapping(value = "/electricitys/day", method = RequestMethod.POST)
    ResponseEntity<ResultObject> postDay(@RequestBody ElectricityDay electricity);

    /**
     * 新增电量（月）
     * @param electricity 电量对象
     */
    @RequestMapping(value = "/electricitys/month", method = RequestMethod.POST)
    ResponseEntity<ResultObject> postMonth(@RequestBody ElectricityMonth electricity);

    /**
     * 批量新增电量（日）
     * @param domainList 电量对象列表
     */
    @RequestMapping(value = "/electricitys/day/batch", method = RequestMethod.POST)
    ResponseEntity<ResultObject> postDay(@RequestBody DomainList<ElectricityDay> domainList);

    /**
     * 批量新增电量（月）
     * @param domainList 电量对象列表
     */
    @RequestMapping(value = "/electricitys/month/batch", method = RequestMethod.POST)
    ResponseEntity<ResultObject> postMonth(@RequestBody DomainList<ElectricityMonth> domainList);


    @RequestMapping(value = "/electricitys/day", method = RequestMethod.GET)
    ResponseEntity<ResultObject<List<ElectricityDay>>> searchDay(@RequestParam("dtime") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") List<Date> dtime);
}
